package edu.nctu.csie.jichang.dp.creational;

public class FactoryMethod {
	public static void main(String[] args) {
		FactoryMethodMethod tMethod = new FactoryMethodMethod(new MethodClassA());
		tMethod.open();
		tMethod.close();
		tMethod = new FactoryMethodMethod(new MethodClassB());
		tMethod.open();
		tMethod.close();
	}
}
class FactoryMethodMethod{
	MethodClass object;
	FactoryMethodMethod(MethodClass object){
		this.object = object;
	}
	void open(){object.open();}
	void close(){object.close();};
}
abstract class MethodClass{
	abstract void open();
	abstract void close();
}
class MethodClassA extends MethodClass{
	void open()  { System.out.println("A Open");}
	void close() { System.out.println("A Close");}
}
class MethodClassB extends MethodClass{
	void open()  { System.out.println("B Open");}
	void close() { System.out.println("B Close");}
}